package com.eningqu.aipen;

import android.app.Application;
import android.content.Context;
import android.util.Log;

import com.blankj.utilcode.util.LogUtils;
import com.eningqu.aipen.sdk.NQPenSDK;
import com.kongzue.dialogx.DialogX;
import com.kongzue.dialogx.style.MaterialStyle;
import com.kongzue.dialogx.util.views.ActivityScreenShotImageView;
import com.tencent.bugly.crashreport.CrashReport;

import io.reactivex.functions.Consumer;
import io.reactivex.plugins.RxJavaPlugins;


public class MyApplication extends Application {

    public static Context mContext = null;
    public static Integer isConnect = -1;

    @Override
    public void onCreate() {
        super.onCreate();
        mContext = getApplicationContext();

        //设置第三方库dialogx全局样式
        DialogX.init(this);
        DialogX.globalStyle= MaterialStyle.style();
        /**
         * FullScreenDialog 对话框实现背景下沉的原理是对当前显示的界面进行截图并对截图进行缩放，
         * 此时界面理论上可以不再进行渲染，您可以通过以下代码启用在 FullScreenDialog
         * 启动时隐藏并阻止当前 Activity 界面进行重测量和渲染，
         * 这样有助于在 FullScreenDialog 使用复杂布局时减少卡顿现象
         */
        ActivityScreenShotImageView.hideContentView = true;


        //初始化Tencent Bugly
        CrashReport.initCrashReport(getApplicationContext(), "835a968d72", false);
        //1.初始化nqpen sdk
        NQPenSDK.getInstance().logSwitch(this, false, false);
        LogUtils.getConfig().setLogSwitch(true);
        LogUtils.getConfig().setLog2FileSwitch(true);

        //2.配置RxJava
        RxJavaPlugins.setErrorHandler(new Consumer<Throwable>() {
            @Override
            public void accept(Throwable throwable) throws Exception {
                Log.i("TAG", "setErrorHandler : "+throwable.toString());
            }
        });
    }
}

